package models

import (
	"time"

	"gorm.io/gorm"
)

type TaskTypeDao struct {
	Id        int       `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
	Typeid    int       `gorm:"column:typeid;type:int(11);NOT NULL" json:"typeid"`
	Typename  string    `gorm:"column:typename;type:varchar(100);NOT NULL" json:"typename"`
	CreatedAt time.Time `gorm:"column:created_at;type:timestamp" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp" json:"updated_at"`
}

func (s *TaskTypeDao) TableName() string {
	return "task_type"
}

func (s *TaskTypeDao) Find(tx *gorm.DB) ([]*TaskTypeDao, error) {
	tx = tx.Model(&s)
	var list []*TaskTypeDao
	if err := tx.Order("id desc").Find(&list).Error; err != nil {
		return list, err
	}
	return list, nil
}
